package top.llove.config;

import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatConnectorCustomizer;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * Tomcat配置
 *
 * @author: 幸会
 * @date: 2021/6/21 14:44
 * @email: 1846724873@qq.com
 * @description: Tomcat配置
 * version: 1.0
 */
@Configuration
public class TomcatConfig {
    @Bean
    public ConfigurableServletWebServerFactory webServerFactory() {
        TomcatServletWebServerFactory factory = new TomcatServletWebServerFactory();
        factory.addConnectorCustomizers(new TomcatConnectorCustomizer() {
            @Override
            public void customize(Connector connector) {
                //允许特殊字符
                connector.setProperty("relaxedQueryChars",  "\"<>[\\]^`{|}");
                connector.setProperty("relaxedPathChars",  "\"<>[\\]^`{|}");
            }
        });
        return factory;
    }

}
